package com.order.service;

import com.order.entity.TechCategory;
import com.order.mapper.TechCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 技术分类服务
 */
@Service
public class CategoryService {

    @Autowired
    private TechCategoryMapper techCategoryMapper;

    /**
     * 获取所有分类
     */
    public List<TechCategory> getAllCategories() {
        return techCategoryMapper.selectAll();
    }

    /**
     * 根据ID获取分类
     */
    public TechCategory getCategoryById(Long id) {
        return techCategoryMapper.selectById(id);
    }

    /**
     * 创建分类
     */
    public void createCategory(TechCategory category) {
        techCategoryMapper.insert(category);
    }

    /**
     * 更新分类
     */
    public void updateCategory(TechCategory category) {
        techCategoryMapper.updateById(category);
    }

    /**
     * 删除分类
     */
    public void deleteCategory(Long id) {
        techCategoryMapper.deleteById(id);
    }
}